home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 1 / CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso / Aminet / misc / sci / r4utils.lha / R4Utils / r4utils.doc < prev    next >
Text File  |  1995-06-14  |  6KB  |  165 lines

  1. R4utils 1.0
  2.  
  3. Introduction.
  4. In the archive you will find three little utilities:
  5.     - rl is a quick and dirty implementation of the Lucy-Richardson restoration
  6.          algorithm.
  7.     - tf performs a 2D Discrete Fourier Transform (DFT) on a R4 binary image.
  8.     - an gives some stats on the distribuition of values in an image and its DFT.
  9.  
  10. Requirements.
  11. An Amiga computer :)
  12. OS V2+
  13.  
  14. RAM requirements.
  15. The rl utility is memory hungry: you will need about 2.5MB in order to restore
  16. a 256x256 R4 binary image. All the utilities are a lot faster if they can
  17. allocate FAST RAM.
  18.  
  19. Installation.
  20. In the archive you will find two versions for each utility:
  21.     - #?.881 is for 680X0+68881 systems (with X>2)
  22.     - #?.000 is for vanilla 68000 systems
  23. so simply copy the version that fits your system where you want.
  24.  
  25. Some information about implementation.
  26. Each program uses the Fast Fourier Transform (FFT) C routine I wrote, so
  27. they are quite slow ;) 2D FFT is really a "heavy" computation and should
  28. be computed only on really fast systems: don't expect to use your A500
  29. to compute a rl restoration with 500 iterations. Using a math coprocessor
  30. is zillion times faster if you have one.
  31.  
  32. Q&A.
  33. What is the R4 image format?
  34. Well, R4 is not actually an image format; in fact it is basically a raw
  35. concatenation of 32 bit floating point values. This type of file is often
  36. used to store real digitised images from some instrument (e.g. the HST
  37. camera, HST being Hubble Space Telescope) and moreover is damn easy to
  38. read and write in every programming languages.
  39.  
  40. How can I display R4 binary images on the Amiga?
  41. Until now there's only one way I know of: use my sao2pgm conversion
  42. utility as found on Aminet; this program is a quick hack I wrote, it
  43. converts R4 binary images in the PGM P5 format. On X Unix machines you
  44. can use SaoImage to display these files: let's hope someone will port it
  45. under AmigaOS, it would be much nicer :)
  46.  
  47. Why are these utils shell only? and why is the interface so ugly?
  48. Cause I had to mantain source level compatibility with Unix and so
  49. I could not use Amiga specific features. :( However some standard
  50. Ansi functions were substituted with Exec and Dos ones where possible.
  51.  
  52. Why are they so buggy?
  53. Well I can't tell you. I've used these utilities for several months now
  54. and on my system all is fine. Contact me if you have problems.
  55.  
  56.  
  57. RL.
  58. This utility performs the Lucy-Richardson restoration algorithm on a
  59. degraded image. This method is quite popular for restoration of HST
  60. WF/PC and FOC images. Look at ftp.stsci.edu (the HST internet home) to
  61. know more about this algorithm.
  62. The syntax is:
  63.  rl <# iter> <width> <height> <infile> <psffile> <outfile> <adu> <noise> [<startfile>]
  64. where
  65.     - <# iter> is the number of iterations
  66.     - <width> and <height> the dimensions for the image to restore
  67.     - <infile> the degraded image
  68.     - <psffile> the image containing the Point Spread Function (PSF)
  69.     - <outfile> the restored output image
  70.     - <adu> and <noise> are values associated with noise (more on these below)
  71.     - <startfile> is the optional image to start with
  72.  
  73. Currently width and height must be equal and a power of two.
  74.  
  75. Adu and noise.
  76. Adu is number of electrons per DataNumber(DN)
  77. Noise is the constant noise
  78. These values are used to compute the Square Chi for the pixel distribuition.
  79. A good rule to stop the iteration is to look at this value and stop
  80. when it is near 1 or when it does not change meaningfully.
  81.  
  82. Startfile specification.
  83. If startfile is specified the rl loads it and starts the iteration
  84. using it; this is useful for subdividing the iteration in steps:
  85. the first time you run rl don't specify startfile and iterate for say 40 times,
  86. then look at the restored outfile...is it looking good? does the Square
  87. Chi seem to have converged? if yes then you have restored it, if no then
  88. run rl another time using the previous outfile as your new startfile and go on
  89. in this way.
  90.  
  91. Things to look at.
  92. During the iteration the program prints some "markers":
  93.  - the Square Chi and the delta from the previous value.
  94.  - the Distance from the degraded image and the restored image and its delta.
  95.  - the Square Norm for the restored object.
  96. These values are then saved in two separate ASCII files:
  97.  - *.log contains the Square Chi,the Distance and the Square Norm
  98.  - *.diflog contains the deltas
  99. where * is substituted with the outfile name. You can look at these values
  100. using a text editor and graph them using GnuPlot.
  101.  
  102. For the mathematician.
  103. The degradation model used is the classical:
  104.  g = k*o + w
  105. where g is the degraded image, k is the PSF, o the object, w the noise and
  106. the * denotes convolution.
  107.  
  108. Let's call f(j) the j restored object and i(j)=k*f(j) its image.
  109.  
  110. Square Norm for a generic h object is computed as:
  111.  
  112.  ||h||**2 = (sum(for all pixels) of h**2)**2
  113.  
  114. Square Chi for j object is computed as:
  115.  
  116.  sqchi(j) = (sum(for all pixels) of (i(j)-g)**2/(var(i(j))))/(n-1)
  117.  
  118. where n is the width*height and var(i(j)) is:
  119.  
  120.  var(i(j)) = (noise**2)/adu + i(j)/adu
  121.  
  122. The Distance for the j image is computed as:
  123.  
  124.  dist(j) = ||i(j)-g||**2 / ||g||**2
  125.  
  126. TF.
  127. This utility simply performs the 2D DFT of a given R4 binary image.
  128. The syntax is:
  129.  tf <width> <height> <infile> <outfile>
  130. It simply loads the given <width> x <height> R4 infile, transform it and then
  131. saves the result in the R4 outfile.
  132.  
  133. AN.
  134. This utility gives you some information about the distribuition of pixels
  135. in a R4 binary image and its DFT.
  136. The syntax is:
  137.  an <width> <height> <infile>
  138. It basically load the given <width> x <height> R4 infile,prints values,
  139. transforms it,prints values for real and imaginary parts of the DFT,
  140. decompose each pixel value in modulus and phase (angle) and then prints
  141. the values for them.
  142. The values printed for each set are:
  143.  - Min and Max the minimum and maximum values
  144.  - Range = Max - Min
  145.  - Ratio = Max / Min
  146.  - Sum the sum for all pixels
  147.  - Mean the mean value
  148.  - Sigma the standard deviation from the mean
  149. This utility is almost useless, but sometimes it is handy: for example
  150. the Ratio value printed for the modulus of the DFT of a PSF is the
  151. so called "conditioning number", the bigger it is the more ill posed
  152. is the deconvolution problem.
  153.  
  154. Thanks.
  155. I would like to thank two persons at STScI for their kindness:
  156.  Bob Hanisch
  157.  Rick White
  158.  
  159. Credits, flames, etc.. to
  160. Stefano Agostinelli
  161. via Vesuvio 12/11
  162. 16134 Genova - ITALY
  163. IRC: arm
  164. E-mail: agos001@pn.itnet.it
  165.